import 'package:cat_eye/base/base_chang_notifier.dart';
import 'package:cat_eye/bean/home_body_bean.dart';
import 'package:cat_eye/config/url_config.dart';
import 'package:cat_eye/http/http_manager.dart';
import 'package:cat_eye/util/loading_state_widget_util.dart';

/*
* @Package: view_model.home_view_model
* @ClassName: video_details_view_model
* @Author: szj
* @CreateDate: 7/31/21 1:27 PM
*/
class VideoDetailsViewModel extends BaseChangNotifier {
  List<ItemList> itemList = [];

  void loadVideoData(int id) async {
    //正在加载中
    type = LoadingWidget.LOADING;
    await HttpManager.requestHttpData(
      '${UrlConfig.videoRelatedUrl}$id',
      onSuccess: (json) {
        var bean = IssueList.fromJson(json);
        itemList.addAll(bean.itemList);
        //停止
        type = LoadingWidget.DONG;
      },
      onFail: (e) {
        //失败
        type = LoadingWidget.ERROR;
      },
      complete: () => notifyListeners(),
    );
  }
}
